/**
 * 
 */
package com.globalresources.ui.struts.action.city;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;
import com.globalresources.commons.AbstractAction;
import com.globalresources.business.inface.ICityService;
import com.globalresources.po.City;
/**
 * @author songduanlei@gmail.com
 * @time Aug 6, 2009 6:55:39 PM
 */
public class CityAction extends AbstractAction implements ServletRequestAware {
	private HttpServletRequest request;
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}		
	private List<City> citys;
	private City city;
	private ICityService cityService;
	private String message;
	
	public String listCitys(){
		citys=cityService.listCity();	
		return SUCCESS;
		
	}
	public String editCity(){
		String id=request.getParameter("id");
		city=cityService.getCityById(id);
		return SUCCESS;
	 }
	public String deleteCity(){
		String id=request.getParameter("id");
		city=cityService.getCityById(id);
		cityService.deleteCity(city);
		setMessage("delete City Success, Please continue your work");
		return SUCCESS;		
	}
	public String saveCity(){
		cityService.saveCity(city);
		setMessage("save City Success, Please continue your work");
		return SUCCESS;
	}
	
	public String saveOrUpdateCity(){
		cityService.saveOrUpdateCity(city);
		setMessage("save or Update City Success, Please continue your work");
		return SUCCESS;
	}
	/**
	 * @return the citys
	 */
	public List<City> getCitys() {
		return citys;
	}
	/**
	 * @param citys the citys to set
	 */
	public void setCitys(List<City> citys) {
		this.citys = citys;
	}
	/**
	 * @return the city
	 */
	public City getCity() {
		return city;
	}
	/**
	 * @param city the city to set
	 */
	public void setCity(City city) {
		this.city = city;
	}
	/**
	 * @return the cityService
	 */
	public ICityService getCityService() {
		return cityService;
	}
	/**
	 * @param cityService the cityService to set
	 */
	public void setCityService(ICityService cityService) {
		this.cityService = cityService;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
}
